package com.ogawa.base.utils

import android.text.TextUtils


fun isEmptyStr(s: String?) : Boolean{
    try{
        if (s == null || TextUtils.isEmpty(s) || "null".equals(s.toLowerCase())){
            return true
        }
    }catch (e:Exception){
        e.printStackTrace()
        return false
    }

    return false
}

fun printNoNull(s: Any?): String {
    try {
        if (isEmptyStr(s.toString())) {
            return ""
        } else {
            return s.toString()
        }
    }catch (e:Exception){
        e.printStackTrace()
    }
    return ""
}

fun trimStr(s:String) :String{
    try{
        var sb = StringBuffer()
        for (item in s){
            if (item !=' '&&item !='\r'&&item !='\n'){
                sb.append(item)
            }
        }
        return sb.toString()
    }catch (e:Exception){
        e.printStackTrace()
    }
    return ""

}
fun trimRRStr(s:String) :String{
    try{
        var sb = StringBuffer()
        for (item in s){
            if (item !='\r'){
                sb.append(item)
            }
        }
        return sb.toString()
    }catch (e:Exception){
        e.printStackTrace()
    }
    return  ""
}


fun hideStrCenterPhone(str:String) : String{
    try {
        var stringBuffer = StringBuffer()
        var telSp = str.split("\n")
        for (tel in telSp){
            val mobile = ""+tel
            val maskNumber = mobile.substring(0, 3) + "****" + mobile.substring(7, mobile.length)
            stringBuffer.append(maskNumber).append("\n")
        }
        return stringBuffer.toString()
    }catch (e:Exception){
        e.printStackTrace()
    }


    return str
}



object StringPrintUtils {

}